﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using jnxc.Common;
using LTP.Accounts.Bus;
namespace jnxc.Web.preventionskill
{
    public partial class Add :BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                
                    CKFinder.FileBrowser fileBrowser = new CKFinder.FileBrowser();
                    fileBrowser.BasePath = "../ckfinder/"; //设置CKFinder的基路径 
                    fileBrowser.SetupCKEditor(ckcontent);
                
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int psid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(psid);
                }
                Page.DataBind();
            }

        }
        private void ShowInfo(int psid)
        {
            jnxc.BLL.preventionskill bll = new jnxc.BLL.preventionskill();
            jnxc.Model.preventionskill model = bll.GetModel(psid);            
            this.hfhid.Value = model.hid.ToString();
            hfpsid.Value = model.psid.ToString();
           ckcontent.Text = model.psinfo;            

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";

            int hid = 0,psid=0;
            if (hfhid.Value.ToString() != "")
            {
                hid = int.Parse(hfhid.Value.ToString());
                string psinfo = ckcontent.Text;
                if (hfpsid.Value.ToString() != "")
                {
                    psid = int.Parse(hfpsid.Value.ToString());

                }
                jnxc.Model.preventionskill model = new jnxc.Model.preventionskill();
                model.hid = hid;
                model.psinfo = psinfo;
                model.psid = psid;
                jnxc.BLL.preventionskill bll = new jnxc.BLL.preventionskill();
                if (model.psid == 0)
                    bll.Add(model);
                else
                {
                    bll.Update(model);
                }
                jnxc.Common.MessageBox.ShowAndRedirect(this, "保存成功！","list.aspx");
            }           

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
